package com.numbfish.ch03_ex04_module_a_stater.config;

import com.numbfish.ch03_ex04_module_a_stater.pojo.PersonFromModuleA;
import com.numbfish.ch03_ex04_module_a_stater.pojo.PersonProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
// 可以扫描OtherConfig @ComponentScan注解用于配置Spring容器在启动时要扫描的包路径，以查找标记有@Component注解的类
@ComponentScan
@EnableConfigurationProperties(value =PersonProperties.class)
public class CustomAutoConfiguration {
    @Autowired
    PersonProperties personProperties;
    @Bean
    public PersonFromModuleA persona1(){
        return new PersonFromModuleA(personProperties.getName(),personProperties.getAge());
    }
}
